<script setup>
import useStorage from "@/hooks/useStorage";

const { setStorage, getStorage, removeStorage, clearStorage } = useStorage();
const handleStorage = async () => await setStorage("testStorage", "123123123");
async function handleGetStorage() {
  // eslint-disable-next-line no-console
  return console.log("测试本地缓存=》", getStorage("testStorage"));
}
const handleRemoveStorage = async () => removeStorage("testStorage");
const handleClearStorage = async () => clearStorage();
</script>

<template>
  <view class="container">
    <s-nav-bar />
    <view class="container-main" flex flex-col>
      <uv-button type="primary" text="本地缓存触发" @click="handleStorage" />
      <view style="height: 50upx" />
      <uv-button
        type="primary"
        text="读取本地缓存(控制台查看)"
        @click="handleGetStorage"
      />
      <view style="height: 50upx" />
      <uv-button
        type="primary"
        text="删除本地缓存"
        @click="handleRemoveStorage"
      />
      <view style="height: 50upx" />
      <uv-button
        type="primary"
        text="清空本地缓存"
        @click="handleClearStorage"
      />
    </view>
  </view>
</template>

<style lang="scss" scoped></style>
